import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import LoginPageView from '../views/LoginPageView.vue'
import HomePageView from '../views/HomePageView.vue'
import previewView from '../views/previewView.vue'
import ResourceListView from '../views/ResourceListView.vue'
import ScanResourceView from '../views/ScanResourceView.vue'
import SystemConfigurationView from '../views/SystemConfigurationView.vue'
import PlayListConfigurationView from '../views/PlayListConfigurationView.vue'
import AddProgramView from '../views/AddProgramView.vue'
import PlanProgramView from '../views/PlanProgramView.vue'
import MainView from '../views/MainView.vue'
import SetProgramView from '../views/SetProgramView.vue'
import previewViewFlv from '../views/previewViewWithFlv.vue'
import testView from '../views/test.vue'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
// 修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'login',
    component: LoginPageView
  },
  {
    path: '/test',
    name: 'test',
    component: testView
  },
  {
    path: '/home',
    name: 'home',
    component: HomePageView,
    children: [
      {
        path: "/",
        redirect: "/preView"
      },
      {
        path: "/preview",
        name: "preview",
        component: previewViewFlv
      },
      {
        path: "/previewFlv",
        name: "previewFlv",
        component: previewViewFlv
      },
      {
        path: "/ResourceList",
        name: "ResourceList",
        component: ResourceListView
      },
      {
        path: "/scanResource",
        name: "scanResource",
        component: ScanResourceView
      },
      {
        path: '/systemConfiguration',
        name: "systemConfiguration",
        component: SystemConfigurationView
      },
      {
        path: "/playListConfiguration",
        name: "playListConfiguration",
        component: PlayListConfigurationView
      },
      {
        path: "/AddProgramView",
        name: "AddProgram",
        component: AddProgramView
      },
      {
        path:"/PlanProgramView",
        name:"PlanProgram",
        component:PlanProgramView
      },
      {
        path:"/Main",
        name:"main",
        component:MainView
      },
      {
        path:"/SetProgram",
        name:"setProgram",
        component:SetProgramView
      }
    ]
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
